package com.example.demo;

import com.example.demo.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@RequestMapping("/resp")
@Controller

public class ResponseController {

    @ResponseBody
    @RequestMapping("/index")
    public String staticPage() {
        return "/index.html";
    }

    @RequestMapping("/css")
    @ResponseBody
    public String css(){
        return "/b.css";
    }

    @RequestMapping("/js")
    public String js(){
        return "/a.js";
    }


    @RequestMapping("/user")
    @ResponseBody
    public User user(){
        User user = new User();
        user.setAge(18);
        user.setName("zhangsan");
        return user;
    }


    @RequestMapping(value = "/map")
    @ResponseBody
    public Map<String, String> map(HttpServletResponse response) {
        response.setHeader("Content-type", "application/json;charset=UTF-8");
        response.setStatus(401);
        Map<String,String> map = new HashMap();
        map.put("name","zhangsan");
        map.put("age","18");
        return map;
    }


    @RequestMapping("/hmtl")
    public String hmtl(){
        return "<h1>我是html<h1>";
    }





}
